<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="./iconfont/iconfont.css" />
    <link rel="stylesheet" href="./css/common.css" />
    <link rel="stylesheet" href="./css/index.css" />
    <script src="./js/index.js"></script>
  </head>
  <body>
    <script src="./js/rem.js"></script>
    <!-- 头部 -->
    <header>
      <!-- 1、json获取 -->
      <ul class="nav"></ul>
      <!-- 轮播图 search-wrap  -->
      <div class="search-wrap">
        <div class="search">
          <i class="iconfont icon-search"></i>
          <input type="text" placeholder="斗罗大陆" id="search" />
        </div>
        <i class="iconfont icon-data"></i>
        <i class="iconfont icon-link"></i>
        <i class="iconfont icon-play-fill"></i>
      </div>
    </header>
    <!-- 电影列表 -->
    <main>
        <!-- 2、json获取 -->
      <h4>猜你喜欢</h4>
      <ul class="list"></ul>
    </main>
    <div class="search-content">
      <p>抱歉，无法找到名称为 <span></span>的相关内容</p>
      <button id="closeDialog">关闭弹框</button>
    </div>

    <!-- 底部导航 -->
    <footer>
      <a href="./index.html">
        <img src="./images/tabbar/2-1.png" alt="" />
        <p>首页</p>
      </a>
      <a href="./vip.html">
        <img src="./images/tabbar/4.png" alt="" />
        <p>vip</p>
      </a>
      <a href="./hotChat.html">
        <img src="./images/tabbar/1.png" alt="" />
        <p>热议</p>
      </a>
      <a href="./my.html">
        <img src="./images/tabbar/3.png" alt="" />
        <p>我的</p>
      </a>
    </footer>
    <a href="###" id="up">
      <i class="iconfont icon-arrow-up"></i>
    </a>
  </body>
  <script>
    // 导航栏 json
    var xhr = new XMLHttpRequest();
    xhr.open("get", "json/nav.json", true);
    xhr.send();
    xhr.onreadystatechange = function () {
      if (xhr.readyState == 4 && xhr.status == 200) {
        var data = JSON.parse(xhr.responseText);
        // 2.渲染数据
        var str = "";
        for (var i = 0; i < data.length; i++) {
          str += ` <li><a href="${data[i].src}">${data[i].name}</a></li>`;
        }
        document.querySelector(".nav").innerHTML += str;
      }
    };
      //  猜你喜欢 json
    var xh = new XMLHttpRequest();
    xh.open("get", "json/like.json", true);
    xh.send();
    xh.onreadystatechange = function () {
      if (xh.readyState == 4 && xh.status == 200) {
        var dataa = JSON.parse(xh.responseText);
        // 2.渲染数据
        var strr = "";
        for (var i = 0; i < dataa.length; i++) {
          strr += `
          <li>
            <img src=${dataa[i].pic} alt="" />
            <p>${dataa[i].text}</p>
            <span>${dataa[i].com}</span>
          </li>
          `;
        }
        document.querySelector(".list").innerHTML += strr;
      }
    };
  </script>
</html>
